#!/sbin/openrc-run
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

depend() {
	use net
}

IRCD_USER=${IRCD_USER:-ircd}

checkconfig() {
	if [ ! -e /etc/ircd/ircd.conf ] ; then
		eerror "You need to create /etc/ircd/ircd.conf first."
		eerror "An example can be found in /etc/ircd/ircd.conf.example"
		return 1
	fi
}

start() {
        checkconfig || return $?
	ebegin "Starting ircd"
	start-stop-daemon --start --quiet --chuid "${IRCD_USER}" --exec /usr/sbin/ircd -- ${IRCD_OPTS}
	eend $?
}

stop() {
	ebegin "Stopping ircd"
	start-stop-daemon --stop --quiet --pidfile /var/run/ircd/ircd.pid
	eend $?
}
